﻿using System;
using System.Collections.Generic;
using msilgc.cbuilder.CSyntaxTree;

namespace msilgc.cbuilder.CBuilder
{
    internal class VariableFactory {

        public List<IVariable> CreatedVariables { get; private set; }
        private int _next = (-1);

        public VariableFactory() {
            CreatedVariables = new List<IVariable>();
        }

        public IVariable CreateNext(IVariable template)
        {
            IVariable var = CreateNext(template.Type);
            var.IsPointer = template.IsPointer;
            return var;
        }

        public IVariable CreateNext(Type type) {
            Variable var = new Variable("var_" + (++_next).ToString(), type);
            CreatedVariables.Add(var);
            return var;
        }
    }
}